package cn.com.jslh.boarpro.main.presenter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;

import com.alibaba.fastjson.JSON;

import net.idik.lib.slimadapter.SlimAdapter;
import net.idik.lib.slimadapter.SlimAdapterEx;
import net.idik.lib.slimadapter.SlimInjector;
import net.idik.lib.slimadapter.viewinjector.IViewInjector;

import org.json.JSONException;

import java.util.List;

import cn.com.jslh.boarpro.R;
import cn.com.jslh.boarpro.base.mvp.BaseListModel;
import cn.com.jslh.boarpro.base.mvp.BaseListPresenter;
import cn.com.jslh.boarpro.base.mvp.BaseListView;
import cn.com.jslh.boarpro.main.entity.NewsWarnEnity;
import cn.com.jslh.boarpro.main.model.NewsWarnModelImpl;
import cn.com.jslh.boarpro.main.view.NewsWarnActivity;
import cn.com.jslh.boarpro.util.WebService;
import cn.com.jslh.boarpro.util.adapter.NewsWarnAadpter;

/**
 * Created by lenovo on 2018/3/24.
 */

public class NewsWarnPresenterImpl  {
    private Context context;
    private NewsWarnAadpter adapter;
    private NewsWarnEnity info;
    private List<NewsWarnEnity> list;
    private RecyclerView recyclerView;

    public NewsWarnPresenterImpl(Context context,RecyclerView recyclerView) {
        this.context = context;
        this.recyclerView=recyclerView;
        adapter=new NewsWarnAadpter(R.layout.news_warn_item);

    }

    public void getData(String lineId){
        new NewsWarnModelImpl(context).getNewsWranData(new WebService.NetSuccessListener() {
            @Override
            public void Success(String s) throws JSONException {
                NewsWarnEnity entity= JSON.parseObject(s,NewsWarnEnity.class);
                info=entity.getData();
                list=info.getWarning();
                adapter.addData(list,true);
                adapter.notifyDataSetChanged();
                recyclerView.setAdapter(adapter);
            }
        },lineId);
    }
}
